<?php
/**
 * AdminController is an instance of Controller (application.components). 
 *
 * Controller is an instance of CController (system.web).
 * CController manages a set of actions which deal with the corresponding user requests. 
 * Through the actions, CController coordinates the data flow between models and views. 
 *
 * Eduow :  International system for education (http://eduow.com)
 * Copyright 2010, Nikolay Stoitsev 
 *
 * Licensed under GNU General Public License version 2
 * Redistributions of files must retain the above copyright notice.
 *
 * @filesource
 * @copyright     Copyright 2010
 * @link          http://eduow.com Eduow Project
 * @package       eduow
 * @subpackage    application.controllers
 * @inheritance   class AdminController » Controller » CController » CBaseController » CComponent
 * @implements    
 * @since         Eduow v 0.0.3
 * @license       http://www.gnu.org/licenses/gpl-2.0.html GNU General Public License version 2
 */

class AdminController extends Controller
{
	public $defaultAction='index';

	/**
	 * @return array action filters
	 */	
	public function filters() {
		return array(
			'accessControl', // perform access control for CRUD operations
		);
	}

	/**
	 * @return array of external action classes
	 */
	public function actions() {
        	return array(
            		'dispatch'=>'application.controllers.admin.DispatchAction',
        	);
        }

	/**
	 * Specifies the access control rules.
	 * This method is used by the 'accessControl' filter.
	 * @return array access control rules
	 */
	public function accessRules() {
		return array(
			'*' => array(Group::ADMIN, 'min'), //all actions require use to be at least an admin
		);
	}

	/**
	 * Display admin page.
	 */
	public function actionIndex() {
		$this->render('index');
	}

	/**
	 * Comand line interface for admin puproses.
	 */
	public function actionShell() {
		$model = new ShellForm;
		$this->render('shell',array('model'=>$model));
	}

	/**
	 * Display admin statistic for user activity.
	 */
	public function actionStatistic() {
		$dataProvider=new CActiveDataProvider('Visit',array(
		'criteria'=>array(
        		'order'=>'visit_date DESC',
    		),
    		'pagination'=>array(
       			'pageSize'=>40,
    			),
		));
		$this->render('statistic',array('dataProvider'=>$dataProvider));
	}

}

?>
